import {observable,action, toJS} from 'mobx';
import CommonStore from '../CommonStore';
import * as SEARCHAPI  from '../../apis/search';
import {WeaForm} from 'comsMobx';
// import { WeaForm } from 'ecCom';
// import * as MultiOptions from '../../components/PlanModul/constants/MultiOptions';

import { FormFields } from '../../components/PlanModul/constants/FormFields';
import {WeaTableNew} from 'comsMobx'
const {TableStore} = WeaTableNew;

export default class WorkPlanSearchStore extends CommonStore {
    test = 'WorkPlanSearch';

    constructor() {
        super();
        this.pageName = 'WorkPlanSearch';
    }

    @observable addWorkPlanFormConditionInfo = FormFields.condition;


    //查看日程弹窗的展示类型 ‘preview’查看日程 ‘share’查看共享
    @observable showType = 'preview';

    @observable topTab = [];
    @observable conditioninfo = [];

    @action
    getCondition(params) {
        SEARCHAPI.getCondition(params).then(action((data) => {
            const { groupinfo, conditioninfo } = data;
            this.conditioninfo = conditioninfo;
            this.topTab = data.groupinfo;
        }));
    }

    @action
    setShowType(showType) {
        this.showType = showType;
    }

    @action
    batchFinish(params) {
        SEARCHAPI.batchFinish({workid : params}).then(rdata=>{
            this.doSearch();
            this.comsWeaTableStore = new TableStore;
        });
    }

    @action
    doFinish(params) {
        SEARCHAPI.doFinish({workid : params}).then(rdata=>{
            this.doSearch();
        });
    }

    @action
    doDelete(params) {
        SEARCHAPI.doDelete({workid : params}).then(rdata=>{
            this.doSearch();
        });
    }


    @action
    exportExcel(dataKey) {
        this.comsWeaTableStore.exportAll();
        // SEARCHAPI.exportExcel(dataKey).then(data => {
        //     if(data.url){
        //         window.location.href = `${location.origin}${data.url}`
        //     }
        // })
    }
}
